package ${package.Controller};

import org.springframework.beans.factory.annotation.Autowired;
import com.lwq.annotation.PermissionController;
import com.lwq.annotation.PermissionInterface;
import com.lwq.annotation.RepeatSubmit;
import com.lwq.annotation.Log;
import org.springframework.web.bind.annotation.*;
import ${superControllerClassPackage};
import com.lwq.model.Dto;
import com.lwq.model.Dtos;
import com.lwq.model.Result;
import javax.validation.Valid;
import com.lwq.util.TableDataInfo;
import ${package.Service}.${table.serviceName};
import ${package.Entity}.${entity};

/**
* Description:
* @author ${author}
* @date ${date}
*/
@PermissionController(type = "${package.ModuleName}")
@RestController
public class ${table.controllerName} extends ${superControllerClass} {

    @Autowired
    private ${table.serviceName} service;

    @GetMapping("${table.entityPath}")
    @PermissionInterface(name="查询${table.comment}", code="${table.entityPath}.query")
    public TableDataInfo queryList(){
        Dto dto = Dtos.newDto(request);
        startPage();
        return getDataTable(service.queryList(dto));
    }

    @PostMapping("${table.entityPath}")
    @PermissionInterface(name="新增${table.comment}", code="${table.entityPath}.add")
    @RepeatSubmit
    @Log
    public Result add(@RequestBody @Valid ${entity} model){
        service.add(model);
        return Result.ok();
    }

    @PutMapping("${table.entityPath}")
    @PermissionInterface(name="修改${table.comment}", code="${table.entityPath}.update")
    @RepeatSubmit
    @Log
    public Result update(@RequestBody @Valid ${entity} model){
        service.update(model);
        return Result.ok();
    }

    @DeleteMapping("${table.entityPath}/{id}")
    @PermissionInterface(name="删除${table.comment}", code="${table.entityPath}.remove")
    public Result del(@PathVariable Long id){
        service.del(id);
        return Result.ok();
    }
}